package com.cskaoyan.catmall.exception;

import com.cskaoyan.catmall.model.vo.BaseRespVo;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 创建日期: 2022-01-08-14-11
 * author : WQW
 * description: 异常处理类
 */

@RestControllerAdvice
public class ExceptionControllerAdvice {


    /**
     * @description 如果发生参数验证异常则返回参数不正确
     * @author WQW
     * @date 2022/1/8 14:46
     * @param
     * @param exception
     * @return com.cskaoyan.catmall.model.vo.BaseRespVo
     */
    @ExceptionHandler(ValidationException.class)
    public BaseRespVo validationException(ValidationException exception){
        String message = exception.getMessage();
        return BaseRespVo.validatedFail(message);
    }
}
